package com.zzq.my.jetpacks.jectpackapp.view.rv;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

/*
 * ================================================
 * 描述：子布局通知父布局不要拦截事件，通过requestDisallowInterceptTouchEvent方法干预事件分发过程
重写dispatchTouchEvent()方法，通知通知父层ViewGroup不要拦截点击事件
 * 作者：zhuangzeqin
 * 时间: 2023/8/4 10:49
 * 邮箱：zzq@eeepay.cn
 * 备注:
 * ----------------------------------------------------------------
 * You never know what you can do until you try !
 *      _              _           _     _   ____  _             _ _
 *     / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 *    / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 *   / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 *  /_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 *
 * 签名：最痛苦的事不是我失败了，而是我本可以.--zzq
 * ----------------------------------------------------------------
 * ================================================
 */
public class ChildPresenter extends RecyclerView {
    public ChildPresenter(@NonNull Context context) {
        super(context);
    }

    public ChildPresenter(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public ChildPresenter(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        //父层ViewGroup不要拦截点击事件
        getParent().requestDisallowInterceptTouchEvent(true);
        return super.dispatchTouchEvent(ev);
    }
}
